package com.ti.demo.mcp;

import io.modelcontextprotocol.spec.McpSchema;
import org.springaicommunity.mcp.annotation.McpArg;
import org.springaicommunity.mcp.annotation.McpPrompt;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @description: @McpPrompt
 * The @McpPrompt annotation generates prompt messages for AI interactions.
 * @Author Triagen
 * @Date 2025/10/30 13:52
 */
@Component
public class McpPrompts {

    // Basic Usage
    @McpPrompt(
            name = "greeting",
            description = "Generate a greeting message")
    public McpSchema.GetPromptResult greeting(
            @McpArg(name = "name", description = "User's name", required = true)
            String name) {

        String message = "Hello, " + name + "! How can I help you today?";

        return new McpSchema.GetPromptResult(
                "Greeting",
                List.of(new McpSchema.PromptMessage(McpSchema.Role.ASSISTANT, new McpSchema.TextContent(message)))
        );
    }


    // With Optional Arguments
    @McpPrompt(
            name = "personalized-message",
            description = "Generate a personalized message")
    public McpSchema.GetPromptResult personalizedMessage(
            @McpArg(name = "name", required = true) String name,
            @McpArg(name = "age", required = false) Integer age,
            @McpArg(name = "interests", required = false) String interests) {

        StringBuilder message = new StringBuilder();
        message.append("Hello, ").append(name).append("!\n\n");

        if (age != null) {
            message.append("At ").append(age).append(" years old, ");
            // Add age-specific content
        }

        if (interests != null && !interests.isEmpty()) {
            message.append("Your interest in ").append(interests);
            // Add interest-specific content
        }

        return new McpSchema.GetPromptResult(
                "Personalized Message",
                List.of(new McpSchema.PromptMessage(McpSchema.Role.ASSISTANT, new McpSchema.TextContent(message.toString())))
        );
    }
}
